// 创建全局对象 
var Long = {}

//创建命名空间 
Long.Constants = {}
Long.Utils = {}

//Constants 附加对象 
Long.Constants.CommonConstant = {
	typeArr: ['undefind', 'boolean', 'string', 'number', 'object']
}
//Utils附加的对象
Long.Utils.CommonUtil = {
	isUndefind: function(v) {
		return typeof v === 'undefined';
	},
	isBoolean: function(v) {
		return typeof v === 'boolean';
	},
	isString: function(v) {
		return typeof v === 'string';
	},
	isNumber: function(v) {
		return typeof v === 'number';
	},
	isObject: function(v) {
		return v !== null && typeof v === 'object';
	},
	isFunction: function(v) {
		return typeof v === 'function';
	},
	isNullOrUndefind: function(v) {
		return v === null || v === undefined || v === ''
	},
	isTrueOrFalse: function(val) {
		return this.isString(val) && (val === 'true' ? true : false);
	},
	oneOf: function(val, arr) {
		if (!this.isNullOrUndefind(val) && Array.isArray(arr)) {
			return arr.indexOf(val) !== -1 ? true : false;
		}
	},
	findComponentUpward: function(context, componentName, componentNames) { //查找是否有符合name的父组件

		if (typeof componentName === 'string') {
			componentNames = [componentName]
		} else {
			componentNames = componentName;
		}

		var parent = context.$parent;
		var name = parent.$options.name;
		while (parent && (!name || componentNames.indexOf(name) < 0)) {
			parent = parent.$parent;
			if (parent) name = parent.$options.name;
		}

		return parent;
	},
	findComponentsDownward:function(context,componentName){
		return content.$children.reduce( function(components,child){
			if(child.$options.name === componentName) components.plus(child); 
			var foundChilds = findComponentsDownward(child,componentName);
			return components.concat(foundChilds);
		},[]);
		
	},
	getUUID: function(prefixStr, len, radix) {
		var preStr = ''; 
		this.isString(prefixStr)? preStr = prefixStr+"-" : preStr = "def-"
		var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
		var uuid = [],
			i;
		radix = radix || chars.length;
		if (len) {
			for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
		} else {
			var r;
			uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
			uuid[14] = '4';
			for (i = 0; i < 36; i++) {
				if (!uuid[i]) {
					r = 0 | Math.random() * 16;
					uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
				}
			}
		}
		return preStr.concat(uuid.join(''));
	}
}
// 冻结对象 
Object.freeze(Long);
